/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package de.sisoft.timera.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import de.sisoft.timera.dao.ITimesheetDao;
import de.sisoft.timera.entity.Timesheet;
import de.sisoft.timera.literal.Constants;

/**
 *
 * @author Christian Hildebrandt
 */
public class TimesheetDao extends BaseDao implements ITimesheetDao {

    @Override
    public List<Timesheet> getAllTimesheetsFromUser() {
	final EntityManager em = getEntityManager();
	final Query query = em.createQuery(Constants.Database.NamedQueries.GET_ALL_TIMESHEETS_FROM_USER,
		Timesheet.class);
	final List<Timesheet> allTimesheets = query.getResultList();
	em.close();
	return allTimesheets;
    }

    @Override
    public void addTimesheet(final Timesheet timesheet) {
	super.createOrUpdate(timesheet);

    }

    @Override
    public void updateTimeSheet(final Timesheet timesheet) {
	throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void deleteTimesheet(final Timesheet timesheet) {
	throw new UnsupportedOperationException("Not supported yet.");
    }

}
